package com.tedu.openmedical.duplicate.copy_content.controller;

import com.tedu.openmedical.base.response.JsonResult;
import com.tedu.openmedical.duplicate.copy_content.pojo.dto.ContentParam;
import com.tedu.openmedical.duplicate.copy_content.pojo.dto.ContentQuery;
import com.tedu.openmedical.duplicate.copy_content.pojo.vo.CopyContentVO;
import com.tedu.openmedical.duplicate.copy_content.service.CopyContentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "复印内容管理")
@Slf4j
@RestController
@RequestMapping("/v1/duplicate/copy_content/")
public class CopyContentController {
    @Autowired
    private CopyContentService copyContentService;

    @ApiOperation("查询复印内容")
    @GetMapping("select")
    public JsonResult loadContent(ContentQuery query){
        log.debug("加载复印内容,query:{}",query);
        List<CopyContentVO> contents = copyContentService.loadContent(query);
        return JsonResult.ok(contents);
    }

    @ApiOperation("更新复印内容")
    @PostMapping("update")
    public JsonResult updateContent(ContentParam param){
        log.debug("更新或新增复印内容，param:{}",param);
        copyContentService.updateContent(param);
        return JsonResult.ok();
    }

    @ApiOperation("删除复印内容")
    @PostMapping("delete/{id}")
    public JsonResult deleteContent(@PathVariable Integer id){
        log.debug("删除复印内容,id:{}",id);
        copyContentService.deleteContent(id);
        return JsonResult.ok();
    }
}
